/**
 * TestController
 *
 * @description :: Server-side logic for managing Tests
 * @help        :: See http://sailsjs.org/#!/documentation/concepts/Controllers
 */

module.exports = {
  redLockTest: function(req, res) {
    res.end();
    RedLockService.lock("aaaa", function(){
      console.log("111",arguments);
    });
    RedLockService.lock("aaaa", function(){
      console.log("222",arguments);
    });
  },

  getAuthDataTest: function (req, res) {
    res.setHeader("Access-Control-Allow-Origin", "*");
    res.setHeader("Access-Control-Allow-Headers", "Content-Type,Accept,Authorization");
    res.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,UPDATE,DELETE");

    var appid = "123"; //req.query.appid;
    WeChatToken.saveData(appid, {
      "appid": appid,
      "secret": "ad91235d1fdf79e374c09a6379c64c9c",
      "access_token": "dUUPADDUmKWi5l4xLG96nrYDgerwxq4JKTum5e-lh7tHcXkMBuWGJawKPb9I2BFPhp99nYWUDHj404wPkyeZzGSE_EZ2Hr-ioZLuQB2XI_0",
      "token_timestamp": 1444731732846,
      "jsapi_ticket": "kgt8ON7yVITDhtdwci0qeXAktRlu0HpNUYI0f_HMBVGOstAh_befdcRAtA-82O14kiqp8L-8hP8h52oCdLwlXg",
      "ticket_timestamp": 1444731736100
    }, function () {
      console.log(arguments);
      WeChatToken.update({"appid": appid}, {"ip_list": ["12", "23"]}, function () {
        console.log(arguments);
      });
    });
  },
};

